package listbyorder.access001_100.test28;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/5/29 18:09
 */
public class Solution1 {

    // 方法一 暴力破解
    public int strStr(String haystack, String needle) {
        if (haystack.length() < needle.length()) return -1;
        int len = needle.length();
        for (int i = 0; i + len <= haystack.length(); i++) {
            if (haystack.substring(i, i + len).equals(needle)) {
                return i;
            }
        }
        return -1;
    }
}
